package de.cbf.cam.dsa.entity.edit.sf.resolver.act;

import java.util.ArrayList;
import java.util.Collection;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import de.cbf.cam.dsa.entity.edit.sf.resolver.persister_interface.IServicePersister_EntitySf;
import de.cbf.cam.dsa.entity.edit.sf.resolver.service_resolver.IServiceResolver_EntitySf;
import de.cbf.cam.dsa.entity.edit.sf.resolver.service_resolver.ServiceResolver_EntitySf;
import de.cbf.cam.dsa.facet.sf.service.IServiceResolver_FacetSf;
import de.cbf.util.entity.facet.persistence.interfaces.IServPersister;
import de.cbf.util.entity.facet.persistence.resolver.IServiceResolverElement;
import de.cbf.util.entity.facet.persistence.resolver.IServiceResolverFacet;
import de.cbf.util.entity.facet.persistence.resolver.act.AbstractActivatorResolverElement;
import de.cbf.util.entity.facet.persistence.resolver.act.AbstractActivatorResolverEntity;

/**
 * The activator class controls the plug-in life cycle
 */
public class ActivatorResolverEntity_Sf extends AbstractActivatorResolverEntity {
	private static final Log logger = LogFactory.getLog(ActivatorResolverEntity_Sf.class);
	// The plug-in ID
	public static final String PLUGIN_ID = "de.cbf.cam.dsa.entity.edit.sf.resolver"; //$NON-NLS-1$

	// The shared instance
	private static ActivatorResolverEntity_Sf plugin;
	
	/**
	 * The constructor
	 */
	public ActivatorResolverEntity_Sf() {
	}

	@Override
	protected Collection<Class<? extends IServiceResolverFacet>> getFacetResolverClasses() {
		Collection<Class<? extends IServiceResolverFacet>> resultList = new ArrayList<Class<? extends IServiceResolverFacet>>();
		resultList.add(IServiceResolver_FacetSf.class);
		return resultList;
	}

	@Override
	protected IServiceResolverElement createResolverService() {		
		return new ServiceResolver_EntitySf();
	}

	@Override
	protected Class<? extends IServPersister> getServPersisterInterface() {		
		return IServicePersister_EntitySf.class;
	}

	@Override
	protected String[] getServiceResolverInterfacesNames() {		
		return new String[]{IServiceResolver_EntitySf.class.getName()};
	}

	@Override
	protected void setPluginInstance(AbstractActivatorResolverElement newActivatorInstance) {
		if (newActivatorInstance instanceof ActivatorResolverEntity_Sf || newActivatorInstance == null) {
			ActivatorResolverEntity_Sf activator = (ActivatorResolverEntity_Sf) newActivatorInstance;
			plugin = activator;
		} else {			
			String err_msg = "entity of wrong type(expected "
					+ ActivatorResolverEntity_Sf.class.getSimpleName() + "): " + (newActivatorInstance == null ? "null"
							: newActivatorInstance.getClass().getSimpleName());
			logger.error(err_msg);
		}		
	}	
	
	/**
	 * Returns the shared instance
	 *
	 * @return the shared instance
	 */
	public static ActivatorResolverEntity_Sf getDefault() {
		return plugin;
	}

	@Override
	protected String getPlugin_ID() {		
		return PLUGIN_ID;
	}

}
